/*
package com.bonc.function;

import com.bonc.entity.BaowenEntity;
import org.apache.kafka.clients.producer.KafkaProducer;
import org.apache.kafka.clients.producer.ProducerRecord;

import java.io.IOException;
import java.io.InputStream;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

*/
/**
 * @Description: 红外$
 * @Param: $params$
 * @return: $returns$
 * @Author: ciri
 * @Date: $date$
 *//*

public class GetInfrared {
    static Properties prop=new Properties();
    static InputStream is=Thread.currentThread().getContextClassLoader().getSystemResourceAsStream("sword.properties");

    public static void getSensor() throws IOException, SQLException, InterruptedException {
        prop.load(is);
        */
/**
         * 这里建立kafka连接，之建立一次
         *//*

        Properties props = new Properties();
        props.put("bootstrap.servers" ,prop.getProperty("brokerList"));
        props.put("key.serializer" ,"org.apache.kafka.common.serialization.StringSerializer");
        props.put("value.serializer" ,"org.apache.kafka.common.serialization.StringSerializer");
        props.put("acks" ,"1");
        //props.put("connections.max.idle.ms" ,"10000");
        KafkaProducer producer = new KafkaProducer<>(props);
        producer = new KafkaProducer<String, String>(props);


        String ADD_URL=prop.getProperty("lingyuurl");
        String topic =prop.getProperty("topic");

        while (true){
            ArrayList<BaowenEntity> baos = GetInfoFromsql("180");
            for (BaowenEntity bao:baos){
                try{
                    Map<String, String> map = new HashMap<String, String >();
                    String oneKey=bao.getGatewayCode()+":"+bao.getDeviceCode();
           */
/* map.put("type", "1");
            map.put("deviceCode", "80 9A");
            map.put("gatewayCode", "00 00 F0 0B");
            map.put("address", "00");*//*

                    map.put("type",bao.getType().toString());
                    map.put("deviceCode",bao.getDeviceCode());
                    map.put("gatewayCode",bao.getGatewayCode());
                    map.put("address",bao.getAddress());

                    String ret = sendPost(ADD_URL, map);

                    switch (bao.getSensorType()){
                        case "TEMPERATURE":
                            producer.send(new ProducerRecord<String, String>(topic,"TE:"+oneKey,ret));//温度
                            System.out.println("temperature"+ret);
                            break;
                        case "HUMIDITY":
                            producer.send(new ProducerRecord<String, String>(topic,"HU:"+oneKey,ret));//温度
                            System.out.println("humidity"+ret);
                            break;
                        case "NH3":
                            producer.send(new ProducerRecord<String, String>(topic,"NH:"+oneKey,ret));//氨气
                            System.out.println("NH3"+ret);
                            break;
                        case "PM25":
                            producer.send(new ProducerRecord<String, String>(topic,"PM:"+oneKey,ret));//pm25
                            System.out.println("PM25"+ret);
                            break;
                    }
                    //{"data":"15.5","gatewayStatus":"1","deviceStatus":"1","acquisitionTime":"2019-01-20T02:35:13.000+0000","success":"0","message":"查询成功!"}
                }
                catch (Exception e){
                    e.printStackTrace();
                    System.out.println("凌宇平台数据接收出现错误，请检查数据库");
                    continue;
                }
            }
            Thread.sleep(900000);//每隔15分钟取一次
        }
    }
}
*/
